#pragma once

#include "Thread.h"
#include <string>
#include <memory>
#include "../Config/Vault.h"
#include "../DataModule/HanaData.h"
#include "../GrpcModule/GrpcModule.grpc.pb.h"
#include "EnclaveProvider.h"

class SyncData;

class SyncDataThread : public Thread
{
public:
    SyncDataThread(std::string sync_id, SyncData *sync_data, Vault *vault, std::shared_ptr<EnclaveProvider> &enclave_provider);
    virtual ~SyncDataThread();

    virtual bool runLoop() override;

public:
	static int row_size_;

private:

    std::string sync_id_;

    SyncData *sync_data_;
    
    HanaData hana_data_;

    Vault *vault_;

    std::unique_ptr<enclave::EnclaveServer::Stub> stub_;

    std::unique_ptr<::grpc::ClientWriter<::enclave::SyncTableRows>> request_;

    grpc::ClientContext context_;

    enclave::SyncDataResponse sync_data_response_;

    std::shared_ptr<EnclaveProvider> enclave_provider_;

	std::shared_ptr<char> fields_;
};

